package Week4;

import java.util.*;

public class Day21 {
}

//牛客:爱丽丝的人偶
class Main6 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int left = 1 , right = n;
        //先放一个小的，再放一个大的
        while(left <= right){
            System.out.print(left + " ");
            //注意个数是奇数个还是偶数个
            if(left < right)
                System.out.print(right + " ");
            left++;
            right--;
        }
    }
}

//牛客:JD7 集合
class Main7 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt() , m = in.nextInt();
        //利用TreeSet进行去重排序
        TreeSet<Integer> set = new TreeSet<>();
        while(n-- != 0){
            set.add(in.nextInt());
        }

        while(m-- != 0){
            set.add(in.nextInt());
        }

        for(int x : set){
            System.out.print(x + " ");
        }
    }
}

//牛客:DP22 最长回文子序列
class Main8 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length;
        //创建一个dp表，表示i到j位置的最长回文串长度
        int[][] dp = new int[n][n];
        for(int i = n - 1; i >= 0; i--){
            //任意单个字符都为回文串
            dp[i][i] = 1;
            for(int j = i + 1; j < n; j++){
                if(s[i] == s[j]) dp[i][j] = dp[i + 1][j - 1] + 2;
                else dp[i][j] = Math.max(dp[i + 1][j] , dp[i][j - 1]);
            }
        }
        System.out.println(dp[0][n - 1]);
    }
}